import { link } from '../mixins/link'
import { button } from '../mixins/button'
import { VantComponent } from '../common/component'
VantComponent({
  classes: [
    'title-class',
    'label-class',
    'value-class',
    'right-icon-class',
    'hover-class'
  ],
  mixins: [link, button],
  props: {
    title: null,
    value: null,
    openType: String,
    icon: String,
    iconColor: String,
    size: String,
    label: String,
    center: Boolean,
    isLink: Boolean,
    required: Boolean,
    clickable: Boolean,
    titleWidth: String,
    customStyle: String,
    arrowDirection: String,
    useLabelSlot: Boolean,
    rightIcon: String,
    rightIconColor: String,
    border: {
      type: Boolean,
      value: true
    },
    titleStyle: String,
    //
    loading: Boolean,
    disabled: Boolean,
    loadingText: String,
    loadingType: {
      type: String,
      value: 'circular'
    },
    dataset: null,
    loadingSize: {
      type: String,
      value: '16px'
    }
  },
  methods: {
    onClick (event) {
      const { canIUseGetUserProfile, openType, getUserProfileDesc } = this.data
      if (openType) {
        this.$emit('click', event)
        if (openType === 'getUserInfo' && canIUseGetUserProfile) {
          wx.getUserProfile({
            desc: getUserProfileDesc || '  ',
            complete: (userProfile) => {
              this.$emit('getuserinfo', userProfile)
            }
          })
        }
      } else {
        this.$emit('click', event.detail)
        this.jumpLink()
      }
    }
  }
})
